# -*- coding: UTF-8 -*-

import xeres
import interface

# Placement properties
class AlignApply(interface.sheet_property):
	MAP = {\
	'left':xeres.StyleAlignment.left,\
	'middle':xeres.StyleAlignment.middle,\
	'right':xeres.StyleAlignment.right,\
	'top':xeres.StyleAlignment.top,\
	'center':xeres.StyleAlignment.center,\
	'bottom':xeres.StyleAlignment.bottom,\
	}
	HORIZONTAL = ('left','middle','right')
	VERTICAL = ('top','center','bottom')

	def horizontal(self,name,attr):
		if not attr in AlignApply.MAP:
			print "No such type alignment (",attr,") for property '%s'." %name
			return
		if not attr in AlignApply.HORIZONTAL:
			print "Invalid align type for horizontal alignment"
			return
		self.val = AlignApply.MAP[attr]

	def vertical(self,name,attr):
		if not attr in AlignApply.MAP:
			print "No such type alignment (",attr,") for property '%s'." %name
			return
		if not attr in AlignApply.VERTICAL:
			print "Invalid align type for vertical alignment"
			return
		self.val = AlignApply.MAP[attr]

# padding & margin properties
class PaddingMarginApply(interface.sheet_property):
	def set(self,name,attr):
		try:
			self.val = int(attr)
		except ValueError:
			print "Invalid value for property '%s'." %name
